#include <stdio.h>
#include <string.h>

int n;
char tmp[20];;
int hexn;
int _42;
int b1, b2;
int l;

int main() {
	scanf("%d", &_42);

	while (_42--) {
		scanf("%d", &n);
	
		b1 = __builtin_popcount(n);
		
		sprintf(tmp, "%d", n);

		hexn=0;
		l= strlen(tmp);

		for (int i=l-1; i>=0; i--) {
			hexn += (tmp[i]-'0')*(1<<(4*(l-i)));
		}

		b2 = __builtin_popcount(hexn);

		printf("%d %d\n", b1, b2);
	}

	return 0;
}
